function enterToTab(formRef) 
{
 /***
 In all text/pw fields, Enter key focuses the
 next text/textarea/pw element of the specifed form.
 ***/             
 for(var i=0, e=formRef.elements, len=e.length, hasNext=true; i<len && hasNext; i++)
  if( /(^text$)|(password)/.test( e[i].type ) )
  {
   for(var j=i+1; j<len && (/hidden/.test(e[j].type)||!/(^text)|(password)/.test(e[j].type)); j++)
   ;
   hasNext = j!=len;
   
   e[i].onkeypress=new Function("var k=(arguments[0]?arguments[0].which:window.event.keyCode )!=13;\
   if(!k && "+hasNext+")this.form.elements["+(j)+"].focus(); return k;");
  }  
}

/***

Usage: enterToTab(document.forms.myForm);   
(Do not call until form is rendered)

***/